﻿@{
	ViewBag.Title = Resources.SysConferenceModel + ConstValues.strDash + Resources.HuiTongCIS;
}
<div id="menuBar" style="height:35px;">
	<div class="clear"></div>
</div>
<div id="dataGrid"></div>

@section bodyParts {
<div id="detailWindow" class="easyui-window"
	title="@Resources.SysConferenceModel" data-options="closed:true,minimizable:false,iconCls:'icon-save'"
	style="width:1200px; display:none;">
	<div class="main">
		<div class="box clearfix">
			<h3 id="detailWindowTitle" class="tit01"></h3>
			<form id="frmDetail" method="post" enctype="multipart/form-data">
				@Html.AntiForgeryToken()
				<table width="100%" height="100%" id="tblDetail" cellpadding="0" cellspacing="1" border="0" class="tastyle01">
					<tr>
						<td style="text-align: right;" class="w1 c1">@Resources.ModelName：</td>
						<td style="text-align: left;" class="w2 c2">
							<input id="txtModelName" name="ModelName" class="easyui-textbox" style="height:27px; width:300px;" data-options="required:true,validType:['length[1,100]']">
							<input type="hidden" id="hidId" name="id" />
						</td>
						<td style="text-align: right;" class="w1 c1">@Resources.ModelNameEn：</td>
						<td style="text-align: left;" class="w2 c2">
							<input id="txtModelNameEn" name="ModelNameEn" class="easyui-textbox" style="height:27px; width:300px;" data-options="required:true,validType:['length[1,100]']">
						</td>
					</tr>
					<tr>
						<td style="text-align: right;" class="w1 c3">@Resources.Status：</td>
						<td style="text-align: left;" class="w2 c4">
							<select id="ddlStatus" name="Status" class="easyui-combobox" style="height:27px; width:300px;" data-options="editable:false,required:true,panelHeight:'auto'">
								<option value="@ConstValues.Status.正常">@Resources.Normal</option>
								<option value="@ConstValues.Status.暂停">@Resources.Pause</option>
							</select>
						</td>
						<td style="text-align: right;" class="w1 c3">@Resources.Sort：</td>
						<td style="text-align: left;" class="w2 c4">
							<input id="txtSort" name="Sort" class="easyui-numberbox" style="height:27px; width:300px;" />
						</td>
					</tr>
					<tr>
						<td style="text-align: right;" class="w1 c1">@Resources.ModelPic：</td>
						<td style="text-align: left;" class="w2 c2" colspan="3">
							<input id="txtModelPic" name="ModelPic" class="easyui-filebox" style="height:27px; width:840px;" data-options="required:true,prompt:'@Resources.ImportImg', buttonText:'@Resources.ChooseImg', accept:'image/jpeg,image/png,image/gif'" />
							<input type="hidden" id="hidModelPic" name="ModelPicPath" />
							<a href="javascript:void(0)" class="easyui-linkbutton" onclick='$("#txtModelPic").filebox("clear"); $("#hidModelPic").val("");'>@Resources.Clear</a>
						</td>
					</tr>
					<tr>
						<td style="text-align: right;" class="w1 c3">@Resources.ModelDetail：</td>
						<td style="text-align: left;" class="w2 c4" colspan="3">
							<input id="txtModelDetail" name="ModelDetail" class="easyui-textbox" style="height:50px; width:892px;" data-options="multiline:true" />
						</td>
					</tr>
					<tr>
						<td style="text-align: right;" class="w1 c1">@Resources.Remark：</td>
						<td style="text-align: left;" class="w2 c2" colspan="3">
							<input id="txtRemark" name="Remark" class="easyui-textbox" style="height:50px; width:892px;" data-options="multiline:true,validType:['length[1,1000]']" />
						</td>
					</tr>
				</table>
			</form>
			<div class="btnDiv">
				<input type="hidden" id="hdnWindowType" />
				<input type="button" class="gbtn" onclick="saveData();" value="@Resources.Save" />&nbsp;&nbsp;
				<input type="button" class="rbtn" onclick="$('#detailWindow').window('close');" value="@Resources.Cancel" />
			</div>
		</div>
	</div>
</div>
<div id="picWindow" class="easyui-window"
	title="@Resources.SysConferenceModel" data-options="closed:true,minimizable:false,iconCls:'icon-save'"
	style="width:1200px; display:none;">
	<div class="main">
		<div class="box clearfix">
			<h3 id="picWindowTitle" class="tit01"></h3>
			<form id="picDetail" method="post" enctype="multipart/form-data">
				@Html.AntiForgeryToken()
				<table width="100%" height="100%" id="picJudge" cellpadding="0" cellspacing="1" border="0" class="tastyle01">
					<tr>
						<td style="text-align: right;" class="w1 c1">@Resources.ModelPic：</td>
						<td style="text-align: left;" class="w2 c2">
							<img id="showModelPic" style="height:300px; width:300px;" />
						</td>
						<td style="text-align: right;" class="w1 c1">@Resources.ModelDetail：</td>
						<td style="text-align: left;" class="w2 c2">
							<span id="showModelDetail" style="width:360px;word-break:normal;display:block;white-space:pre-wrap;overflow:hidden;"></span>
						</td>
					</tr>
				</table>
			</form>
			<div class="btnDiv">
				<input type="button" class="rbtn" onclick="$('#picWindow').window('close');" value="@Resources.Cancel" />
			</div>
		</div>
	</div>
</div>
}

@section Scripts {
<script>
	common.setCurrentMenu("SysConferenceModel");

	$(function () {
		$("#dataGrid").datagrid({
			url: "@Url.Action(nameof(SysConferenceModelController.GetData),
					nameof(SysConferenceModelController).GetControllerName())",
			method: "get",
			singleSelect: true,
			fitColumns: true,
			width: $(window).width() - 285,
			height: $(window).height() - 80,
			nowrap: false,
			pagination: true,
			pageSize: @ConstValues.DefaultGridRows,
			striped: true,
			toolbar: "#toolBar",
			pageSize: 100, 
			pageList: [100, 200, 300, 400, 500],
			columns: [[
				{ field: "id", hidden: true },
				@if ((User as ICISPrincipal).IsSSA ||
					Utility.HasSystemRole((User as ICISPrincipal), ConstValues.FunctionId.SysConferenceModel, RoleType.修改) ||
					Utility.HasSystemRole((User as ICISPrincipal), ConstValues.FunctionId.SysConferenceModel, RoleType.删除))
				{
					<text>
					{
						field: "operate", title: "@Resources.Operate", align: "center", width: 150,
						formatter: function(value, rec) {
					        	var strInfo = "";
					        	@if ((User as ICISPrincipal).IsSSA || Utility.HasSystemRole((User as ICISPrincipal), ConstValues.FunctionId.SysConferenceModel, RoleType.修改))
							{
								<text>
					        		strInfo += "<a href='#' style='color:#66CDAA;font-weight:bold;text-decoration:underline;' onclick='editData(\""
									+ rec.id + "\")'>@Resources.Modify</a>";
					        		</text>
							}
					        	return strInfo;
						}
					},
					</text>
				}
				{ field: "modelName", title: "@Resources.ModelName", align: "center", sortable: true, width: 150 },
				{
					field: "modelPic", title: "@Resources.ModelPic", align: "center", width: 150,
					formatter: function(value, rec) {
                    				var strInfo = "";
                    				strInfo += "<a href='#' style='color:#66CDAA;font-weight:bold;text-decoration:underline;' onclick='showPic(\""
							+ rec.id + "\",\""+ rec.modelDetail + "\")'>@Resources.ModelPic</a>";
                    				return strInfo;
					}
				},
				{
					field: "status", title: "@Resources.Status", align: "center", sortable: true, width: 100,
					formatter: function(value, rec) {
	                			if(value=="@ConstValues.Status.正常"){
	                				return "@Resources.Normal"
	                			}else{
	                				return "@Resources.Pause"
	                			}
					}
				},
				{ field: "sort", title: "@Resources.Sort", align: "center", sortable: true, width: 100 },
				{ field: "remark", title: "@Resources.Remark", align: "center", sortable: true, width: 200 },
				{ field: "creator", title: "@Resources.Creator", align: "center", sortable: true, width: 100 },
				{ field: "createIP", title: "@Resources.CreateIP", align: "center", sortable: true, width: 150 },
				{ field: "createDate", title: "@Resources.CreateDate", align: "center", sortable: true, width: 150 },
			]],
			onBeforeLoad: function(param) {
				param.random = Math.random();
			}
		});

		$(window).resize(function () {
			$("#dataGrid").datagrid("resize", {
				width: $(window).width() - 285,
				height: $(window).height() - 80
			});
		});

		$("#detailWindow").window({
			onOpen: function () {
				$(this).scrollTop(0);
			},
			top: ($(window).height() - 600) * 0.5
		});

		$("#picWindow").window({
			onOpen: function () {
				$(this).scrollTop(0);
			},
			top: ($(window).height() - 600) * 0.5
		});
	});

	function editData(id) {
		var url = "@Url.Action(nameof(SysConferenceModelController.GetEditData),
				nameof(SysConferenceModelController).GetControllerName())" + "/" + id;
		$.get(url, null, function (data, textStatus, jqXHR) {
			if (data.result == "@ConstValues.AjaxFailResult") {
				common.showError(data.message);
				$("#dataGrid").datagrid("reload");
			} else {
				$("#txtModelName").textbox("setValue",data.data.modelName);
				$("#txtModelNameEn").textbox("setValue",data.data.modelNameEn);
				$("#ddlStatus").combobox("setValue",data.data.status);
				$("#txtSort").numberbox("setValue", data.data.sort);
				$("#txtRemark").textbox("setValue",data.data.remark);
				$("#hidId").val(id);
				$("#hdnWindowType").val("edit");
				$("#txtModelPic").textbox("setText",data.data.modelPic);
				$("#hidModelPic").val(data.data.modelPic);
				$("#txtModelDetail").textbox("setValue",data.data.modelDetail);
				$("#detailWindow").window("open");
			}
		});
	}

	function saveData() {
		var isValid = $("#frmDetail").form("validate");
		var simEnd = $("#txtModelPic").filebox("getText");
		if (simEnd == "") {
			common.showError("@Resources.MsgUploadConferenceModelPic");
			return false;
		}
		if (isValid) {
			if (!/\.(gif|jpg|jpeg|png|GIF|JPG|PNG|JPEG)$/.test(simEnd)){
				common.showError("@Resources.MsgImgType");
				return false;
			}
			$.messager.confirm("@Resources.Save", "@Resources.CfmSave", function (r) {
				if (r) {
					var loading = layer.load(0,  {
						shade: [0.4,"#fff"]
					});

					$("#frmDetail").form({
						iframe: false,
						success: function (data) { }
					});

					switch ($("#hdnWindowType").val())
					{
						case "edit":
							$("#frmDetail").form("submit", {
								url:"@Url.Action(nameof(SysConferenceModelController.Modify), nameof(SysConferenceModelController).GetControllerName())",
								onSubmit: function (param) {
									param.random = Math.random();
								},
								success: function (data) {
									layer.close(loading);
									data = JSON.parse(data);
									if (data.result == "@ConstValues.AjaxFailResult") {
										common.showError(data.message);
									} else {
										common.showSuccess(data.message, true);
										$("#detailWindow").window("close");
										$("#dataGrid").datagrid("reload");
									}
								},
							});
							break;
					}
				}
			})
		}
	};

	function showPic(id , picDetail) {
		$("#showModelPic").attr("src", "@Url.Action(nameof(SysConferenceModelController.ConferenceModelImg),
							nameof(SysConferenceModelController).GetControllerName())" + "/" + id);
		$("span[id='showModelDetail']").html(picDetail);
		$("#picWindow").window("open");
	}
</script>
}